package com.example.druiddemo;

import com.alibaba.druid.filter.FilterChain;
import com.alibaba.druid.filter.FilterEventAdapter;
import com.alibaba.druid.proxy.jdbc.ConnectionProxy;
import lombok.extern.slf4j.Slf4j;

import java.util.Properties;

/**
 * @description: 使用druid扩展点，连接前后打印日志
 * @author: lzp
 * @createTime: 2021-11-19 00:07
 **/
@Slf4j
public class ConnectionLogFilter extends FilterEventAdapter {

    @Override
    public void connection_connectBefore(FilterChain chain, Properties info) {
        log.info("connect before!");
    }

    @Override
    public void connection_connectAfter(ConnectionProxy connection) {
        log.info("connect finished!");
    }
}
